<template>
  <div id="app" :class="header.title ? `padding-top` : ``">
    <LayerHeader />
    <div v-if="false" id="nav">
      <router-link to="/home">首页</router-link>|
      <router-link to="/answer">答题页面</router-link>
      <router-link to="/lotto">抽奖页面</router-link>
      <router-link to="/failure">答题失败页面</router-link>
      <router-link to="/search">垃圾查查</router-link>
      <router-link to="/myCard">我的卡券</router-link>
      <router-link to="/notebook">垃圾分类手册</router-link>
    </div>
    <router-view />
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import LayerHeader from '@/components/layer/header'
export default {
    components: {
        LayerHeader
    },
    data() {
        return {}
    },
    computed: {
        ...mapGetters(['header'])
    },
    created() {
        if (this.getQueryVariable('token')) {
            localStorage.setItem('token', this.getQueryVariable('token'))
            window.location.href = 'http://lj.unmcc.com/#/home'
            // window.location.href = 'http://192.168.8.107:8081/#/home'
        } else {
            if (!localStorage.getItem('token')) {
                console.log(404)
            }
        }

        // console.log(process.env.NODE_ENV)
        // if (process.env.NODE_ENV === 'development') {
        //     alert('您当前所处环境为测试环境, 数据仅供测试使用')
        // }
    },
    methods: {
        getQueryVariable(variable) {
            const query = window.location.search.substring(1)
            const vars = query.split('&')
            for (let i = 0; i < vars.length; i++) {
                const pair = vars[i].split('=')
                if (pair[0] === variable) {
                    return pair[1]
                }
            }
            return false
        }
    }
}
</script>
<style lang="less">
html,
body {
  min-height: 100vh;
  margin: 0;
  font-family: "微软雅黑";
  overflow-x: hidden;
  background-color: #fff;
  .padding-top {
    padding-top: calc(45px);
  }
}
</style>
